package com.wangbo.config.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * 自定义配置
 */
@Configuration
public class CustomConfig {

    /**
     * 读取项目外的配置文件并写入outSettings
     */
    @PostConstruct
    public void init() {
        Properties properties = new Properties();
        try {
            properties.load(new FileInputStream("D:\\temp\\my.properties"));
            System.getProperties().putAll(properties);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Bean
    public OutSettings outSettings() {
        return new OutSettings();
    }
}
